import request from '@/utils/request'

// 查询新闻资讯列表
export function listInformation(query) {
  return request({
    url: '/system/information/list',
    method: 'get',
    params: query
  })
}

// 查询新闻资讯详细
export function getInformation(informationId) {
  return request({
    url: '/system/information/' + informationId,
    method: 'get'
  })
}

// 新增新闻资讯
export function addInformation(data) {
  return request({
    url: '/system/information',
    method: 'post',
    data: data
  })
}

// 修改新闻资讯
export function updateInformation(data) {
  return request({
    url: '/system/information',
    method: 'put',
    data: data
  })
}

// 删除新闻资讯
export function delInformation(informationId) {
  return request({
    url: '/system/information/' + informationId,
    method: 'delete'
  })
}

// 导出新闻资讯
export function exportInformation(query) {
  return request({
    url: '/system/information/export',
    method: 'get',
    params: query
  })
}

// 查询下拉树结构
export function treeselect() {
  return request({
    url: '/system/statute/treeselect',
    method: 'get'
  })
}

// 置顶修改
export function changeTop(informationId, istop) {
  const data = {
    informationId,
    istop
  }
  return request({
    url: '/system/information/changeTop',
    method: 'put',
    data: data
  })
}

//下载文件
export function getFile (url){
  return request({
    url: url,
    method: 'get',
    responseType: 'arraybuffer'
  })
}
